package main

import "fmt"

func numSteps(s string) int {
	var slen int = len(s)
	var num int = 0
	for slen > 1 {
		var b = make([]byte, slen)
		if s[slen-1] == '1' {
			var carry int = 1
			for i := slen - 1; i >= 0; i-- {
				if carry == 1 {
					if s[i] == '1' {
						b[i] = 0 + '0'
						carry = 1
					} else {
						b[i] = 1 + '0'
						carry = 0
					}
				} else {
					b[i] = s[i]
				}
			}
			if carry == 1 {
				s = "1" + string(b)
			} else {
				s = string(b)
			}
		} else {
			s = s[:slen-1]
		}
		slen = len(s)
		num++
	}
	return num
}

func main() {
	fmt.Println(numSteps("1101"))
	fmt.Println(numSteps("10"))
}
